<template>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
        <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="80px"
            style="width: 90%; margin-left:50px;">
            <el-row :gutter="40">
                <el-col :span="24" v-if="dialogStatus === 'create'">
                    <el-form-item label="实体名称" prop="name">
                        <el-input v-model="name" />
                    </el-form-item>
                </el-col>
            </el-row>

            <!-- <el-table ref="table" :key="tableKey" :data="labelGroup" border fit highlight-current-row style="width: 100%;">
                <el-table-column align="center" label="列名" min-width="150px">
                    <template slot-scope="{row}">
                        <span>{{ row.columnName }}</span>
                    </template>
                </el-table-column>

                <el-table-column align="center" label="标签名" min-width="150px">
                    <template slot-scope="{row}">
                        <span>{{ row.labelName }}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center" label="标签值" min-width="150px">
                    <template slot-scope="{row}">
                        <span>{{ row.labelValue }}</span>
                    </template>
                </el-table-column>
            </el-table> -->
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button type="primary"  @click="dialogFormVisible = false">
                {{ $t('table.confirm') }}
            </el-button>
        </div>
  
    </el-dialog>
</template>
  
<script>
import { labelEntityList, entityTable } from '@/api/metadata/entity'
export default {
    name: 'entityForm',
    data() {
        return {
            labelGroup: [],
            tableKey: 2,
            entityeData: [],
            rules: {
            },
            temp: {},
            name: '',
            textMap: {
                update: '编辑',
                create: '新建',
                check:'查看'
            },
            loading: false,
            dialogFormVisible: false,
            dialogStatus: '',
            tableId: '',
            name:''
        }
    },
    methods: {
        setList(data) {
            // console.log(data)
            this.tableId = data.tableId
            labelEntityList(data).then(res => {
                if (res.data.code == 200) {
                    this.entityeData = res.data.data
                }
            })
        },
        //选择实体名称
        choseName(id) {
            entityTable(id).then(res => {
                if (res.data.code == 200) {
                    this.temp={
                        id:res.data.data.id,
                        tableId:res.data.data.tableId,
                        name:res.data.data.name
                    }
                    this.labelGroup = res.data.data ? res.data.data.labelGroup || [] : []
                }
            })
        },
        handleCheck() {
            this.dialogStatus='check'
            this.labelGroup = []
            this.dialogFormVisible = true
            this.$nextTick(() => {
                this.$refs['dataForm'].clearValidate()
            })
        }
    }
}
</script>
<style>
.el-dialog {
    width: 70%;
}
</style>

  